package com.example.interceptor.utils.jwt;

import com.auth0.jwt.interfaces.DecodedJWT;
import org.junit.Test;


import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class JWTUtilsTest {

    @Test
    public void testTokenGenerationAndDecoding() {
       /* // Create payload
        Map<String, String> payload = new HashMap<>();

        payload.put("username", "john_doe");

        // Generate token
        String token = JWTUtils.getToken(payload);
        System.out.println(token);
        assertNotNull(token);*/


        // Decode token
        DecodedJWT decodedJWT = JWTUtils.decode("OKeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhZG1pbiI6Imxpc2kiLCJleHAiOjE2OTQ1OTY4MjF9.NQXM7bqJcawRiTikV1qA-Q6Ntfy4HpJGCo3nndZk2Xg");
        System.out.println(decodedJWT);


        // Verify payload
        System.out.println(decodedJWT.getClaim("admin").asString());


    }
}
